import logging
from redis import StrictRedis


class Config(object):
    """项目的配置"""
    # DEBUG = True
    SECRET_KEY = "YgRLN3hmEy+ByS/92MIckDL8AJ1aikOtyuwOUGkSYKCnX+0CXg0h1Yt32LcU9cU1"
    # 数据库配置信息
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 在请求结束时候，如果指定此配置为 True ，那么 SQLAlchemy 会自动执行一次 db.session.commit()操作
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = "6379"

    SESSION_TYPE = "redis"  # session保存到redis中
    SESSION_USE_SIGNER = True  # 开启session 签名（加密）
    # 指定session保存的redis实例
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    SESSION_PERMANENT = False
    PERMANENT_SESSION_LIFETIME = 86400 * 2  # 设置session的过期时间
    LOG_LEVEL = logging.DEBUG


class DevelopmentConfig(Config):
    DEBUG = True



class ProductConfig(Config):
    DEBUG = False



class TestConfig(Config):
    DEBUG = True
    TESTING = True


config = {
    "development": DevelopmentConfig,
    "product": ProductConfig,
    "test": TestConfig
}